package cn.com.headfree.technician.service.impl;

import cn.com.headfree.entity.TEducateInfo;
import cn.com.headfree.entity.TEmpBaseInfo;
import cn.com.headfree.entity.TSeniorTechnician;
import cn.com.headfree.entity.TYearEffectInfo;
import cn.com.headfree.technician.dao.IUserDataInfoDao;
import cn.com.headfree.technician.service.ExportWordUserDataInfoService;
import cn.com.headfree.technician.service.IUserDataInfoService;
import cn.com.headfree.util.SysDictionaryUtil;
import cn.com.headfree.vo.*;
import com.deepoove.poi.data.DocxRenderData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;


@Service("exportWordUserDataInfoService")
public class ExportWordUserDataInfoServiceImpl implements ExportWordUserDataInfoService {

	private static final Logger LOG = LogManager.getLogger(ExportWordUserDataInfoServiceImpl.class);

	@Autowired
	private IUserDataInfoService userDataInfoService;


	@Override
	public TechnicalReportVo getModelData(String erpNo,String seniorId) {
		//基本信息
		TEmpBaseInfo tEmpBaseInfo = userDataInfoService.getBaseInfoByErpNo(erpNo);
		//申报的信息
		TSeniorTechnician technician = userDataInfoService.getTSeniorTechnicianById(seniorId);
		//文化程度--获取最高学历
		List<TEducateInfo> educateInfo = userDataInfoService.getEducateInfoHighEducByErpNo(erpNo);
		//工作经历
		List<WorkExpInfoVo> tWorkExpInfos = userDataInfoService.getWorkExpInfoByErpNo(erpNo,seniorId);
		//主要学习、培训经历的培训方面
		List<StudyAndTrainVo> educateInfos = userDataInfoService.getEducateInfoByErpNo(erpNo,seniorId);
		List<StudyAndTrainVo> contiStudyTrains = userDataInfoService.getContiStudyInfoByErpNo(erpNo,seniorId);
		educateInfos.addAll(contiStudyTrains);
//		contiStudyTrains.addAll(educateInfos);
		//技术革新、专利、科技创新、项目成果
		//技艺革新
		List<SkillAndTechnicalVo> skillAndTechnicalVos = userDataInfoService.getTecInnovInfoByErpNo(erpNo,seniorId);
		//专利
		List<SkillAndTechnicalVo> patentInfos = userDataInfoService.getPatentInfoByErpNo(erpNo,seniorId);
		//科技创新
		List<SkillAndTechnicalVo> tecManInnovs = userDataInfoService.getTecManInnovByErpNo(erpNo,seniorId);
		//项目成果
		List<SkillAndTechnicalVo> projAchieveInfos = userDataInfoService.getProjAchieveInfoByErpNo(erpNo,seniorId);
//		skillAndTechnicalVos.addAll(patentInfos);
//		skillAndTechnicalVos.addAll(tecManInnovs);
//		skillAndTechnicalVos.addAll(projAchieveInfos);
		projAchieveInfos.addAll(tecManInnovs);
		projAchieveInfos.addAll(patentInfos);
		projAchieveInfos.addAll(skillAndTechnicalVos);
		//编写操作规程、规范、标准、教案及发表论文、著作等情况
		//标准制定
		List<StandAndScienceVo> standAndSciences = userDataInfoService.getStandInfoByErpNo(erpNo,seniorId);
		//学术成果
		List<StandAndScienceVo> acadeAchiveInfos = userDataInfoService.getAcadeAchiveInfoByErpNo(erpNo,seniorId);
//		standAndSciences.addAll(acadeAchiveInfos);
		acadeAchiveInfos.addAll(standAndSciences);
		//参加技能竞赛获奖情况
		//竞赛考试
		List<ContestInfoVo> tContestInfos = userDataInfoService.getContestInfoByErpNo(erpNo,seniorId);
		//承担技艺传授、技能培训工作情况
		//师带徒信息
		List<TeachArtVo> tSdtTutorPrentInfos = userDataInfoService.getTSdtTutorPrentInfoByErpNo(erpNo,seniorId);
		//培训授课的授课方面
		List<TeachArtVo> contiStudyInfos = userDataInfoService.getContiStudyTechInfoByErpNo(erpNo,seniorId);
//		tSdtTutorPrentInfos.addAll(contiStudyInfos);
		contiStudyInfos.addAll(tSdtTutorPrentInfos);
		//获得荣誉称号
		//个人荣誉
		List<HonorDatasVo> honnorInfos = userDataInfoService.getHonnorInfoByErpNo(erpNo,seniorId);
		//专家人才称号
		List<HonorDatasVo> expertTitleInfos = userDataInfoService.getExpertTitleInfoByErpNo(erpNo,seniorId);
		//专业技术资格
		List<HonorDatasVo> proTecInfos = userDataInfoService.getProTecInfoByErpNo(erpNo,seniorId);
		//技能等级
		List<HonorDatasVo> skillLevelInfos = userDataInfoService.getSkillLevelInfoByErpNo(erpNo,seniorId);
//		honnorInfos.addAll(expertTitleInfos);
//		honnorInfos.addAll(proTecInfos);
//		honnorInfos.addAll(skillLevelInfos);
		skillLevelInfos.addAll(proTecInfos);
		skillLevelInfos.addAll(expertTitleInfos);
		skillLevelInfos.addAll(honnorInfos);

		//拼装数据
		TechnicalReportVo technicalReportVo = new TechnicalReportVo();
		LOG.info("组装模板数据开始");
		technicalReportVo.settEmpBaseInfo(tEmpBaseInfo);
		if(technician != null){
			if(educateInfo != null && educateInfo.size()>0){
				technician.setEduInfo(SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications",educateInfo.get(0).getEducName()));
			}
//			technician.setEduInfo(SysDictionaryUtil.getNameByValueForDefault("education",technician.getEduInfo()));
			technicalReportVo.settSeniorTechnician(technician);
		}
		//工作经历
		if (tWorkExpInfos != null && tWorkExpInfos.size() > 0) {
			technicalReportVo.setWorkExpInfoVos(tWorkExpInfos);
		}
		//主要学习、培训经历
		if (educateInfos != null && educateInfos.size() > 0) {
			technicalReportVo.setStudyAndTrainVo(educateInfos);
		}
		//技术革新、专利、科技创新、项目成果
		if (projAchieveInfos != null && projAchieveInfos.size() > 0) {
			technicalReportVo.setSkillAndTechnicalVo(projAchieveInfos);
		}
		//编写操作规程、规范、标准、教案及发表论文、著作等情况
		if (acadeAchiveInfos != null && acadeAchiveInfos.size() > 0) {
			technicalReportVo.setStandAndScienceVo(acadeAchiveInfos);
		}
		//参加技能竞赛获奖情况
		if (tContestInfos != null && tContestInfos.size() > 0) {
			technicalReportVo.setContestInfoVo(tContestInfos);
		}
		//承担技艺传授、技能培训工作情况
		if (contiStudyInfos != null && contiStudyInfos.size() > 0) {
			technicalReportVo.setTeachArtVo(contiStudyInfos);
		}
		//获得荣誉称号
		if (skillLevelInfos != null && skillLevelInfos.size() > 0) {
			technicalReportVo.setHonorDatasVo(skillLevelInfos);
		}
		LOG.info("======================数据组装完成========================");
		return technicalReportVo;
	}


}
